def isprime(n):  # 判断素数函数
    for i in range(2, n):
        if n % i == 0:
            return 0
    return n


def f(n):  # 找小于n的素数并求和
    prime_list = []
    sum = 0
    # 判断素数
    for i in range(n+1):
        prime_list.append(isprime(i))
    # 从大到小排序
    prime_list.sort(reverse=True)
    # 前十个数求和
    for item in prime_list[0:10]:
        sum += item
    return sum


if __name__ == "__main__":
    p = int(input())
    print(f(p))
